﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BomberManServer.Gaming.Object.Mapping.Items;
using BomberManServer.Utils;

namespace BomberManServer.Gaming.Object.Mapping
{
    public class Block
    {
        public Item item { set; get; }
        public Coordinates coordinates { get; private set; }

        public Block(uint x, uint y)
        {
            coordinates = Coordinates.fromBlock(x, y);
        }

        public Block(uint x, uint y, Item item)
        {
            coordinates = Coordinates.fromBlock(x, y);
            this.item = item;
        }

        // return false is it stops propagation
        virtual public bool reactionDeflagration(Deflagration deflagration)
        {
            bool propagate = item.propagation;
            if ((item.destructible) || (item.propagation))
                this.item = this.item.actionDeflagration(deflagration);
            return propagate;
        }

        // We assume we can walk on this block
        virtual public void reactionWalk(Avatar avatar)
        {
            item.actionWalk(this, avatar);
            if(avatar.isAlive)
                item = avatar;
        }
    }
}
